package com.zygh.interactiveplatform.module.controller;


import com.alibaba.fastjson.JSONObject;
import com.zygh.interactiveplatform.common.anno.PcLog;
import com.zygh.interactiveplatform.common.constant.SwaggerTagConst;
import com.zygh.interactiveplatform.common.domain.ResponseDTO;
import com.zygh.interactiveplatform.module.entity.Backups;
import com.zygh.interactiveplatform.module.service.BackupsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lee
 * @since 2021-02-01
 */
@RestController
@RequestMapping("/backups")
@Api(tags = {SwaggerTagConst.Admin.MANAGER_BACKUPS})
public class BackupsController {
    @Resource
    private BackupsService backupsService;

    @ApiOperation(value = "数据备份新增", notes = "数据备份新增")
    @PostMapping("addBackupse")
    @PcLog(logType = "2", module = SwaggerTagConst.Admin.MANAGER_AUTOLOGOS, content = "数据备份新增")
    public ResponseDTO addBackupse(@RequestBody @Valid Backups backups) {
        return backupsService.addBackups(backups);
    }

    @ApiOperation(value = "数据备份修改", notes = "数据备份修改")
    @PostMapping("updateBackups")
    @PcLog(logType = "3", module = SwaggerTagConst.Admin.MANAGER_AUTOLOGOS, content = "数据备份修改")
    public ResponseDTO updateBackups(@RequestBody @Valid Backups backups) {
        return backupsService.updateBackups(backups);
    }

    @ApiOperation(value = "数据备份删除", notes = "数据备份删除")
    @PostMapping("deleteBackups")
    @PcLog(logType = "4", module = SwaggerTagConst.Admin.MANAGER_AUTOLOGOS, content = "数据备份删除")
    public ResponseDTO deleteBackups(@RequestBody String id) {
        String s = JSONObject.parseObject(id).get("id").toString();
        Integer new_id = Integer.parseInt(s);
        return backupsService.deleteBackups(new_id);
    }

    @ApiOperation(value = "查询所有数据备份", notes = "查询所有数据备份")
    @GetMapping("findBackupsAll")
    @PcLog(logType = "1", module = SwaggerTagConst.Admin.MANAGER_AUTOLOGOS, content = "查询所有数据备份")
    public ResponseDTO findBackupsAll(Integer current, Integer size) {
        return backupsService.findBackupsAll(current,size);
    }
    

}
